<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
	protected function _initAutoload() {
		//自动载入也可以在ini中添加，如下autoloaderNamespaces[] = "ZC"
		$autoloader = Zend_Loader_Autoloader::getInstance ();
		$autoloader->registerNamespace ( 'Izwt_' );
		$autoloader->registerNamespace ( 'CU_' );
		$moduleLoader = new Zend_Application_Module_Autoloader ( array ('namespace' => '', 'basePath' => APPLICATION_PATH ) );
		
		return $moduleLoader;
	}
	/*
	protected function _initViewHelpers() {
		$loader = new Zend_Loader_PluginLoader ();
		$loader->addPrefixPath ( 'Izwt_View_Helper', 'Izwt/View/Helper' );
		return $loader;
	}*/
	
	protected function _initDoctype() {
		$this->bootstrap ( 'view' );
		$view = $this->getResource ( 'view' );
		$view->doctype ( 'XHTML1_STRICT' );
	}
	
	protected function _initView() {
		$view = new Zend_View ();
		$view->setEncoding ( 'UTF-8' );
		$view->doctype ( 'XHTML1_STRICT' );
		$options = $this->getOptions ();
		$viewOptions = $options ['resources'] ['view'] ['helperPath'];
		if (is_array ( $viewOptions )) {
			foreach ( $viewOptions as $helperName => $path ) {
				$view->addHelperPath ( $path, $helperName );
			}
		}
		$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer ();
		Zend_Controller_Action_HelperBroker::addHelper ( $viewRenderer );
		$viewRenderer->setView ( $view );
		
		return $view;
	}
	
	protected function _initDB() {
		$options = $this->getOption ( 'resources' );
		$options = $options ['db'];
		
		$resources = $this->getPluginResource ( 'db' );
		$db = $resources->getDbAdapter ();
		Zend_Db_Table::setDefaultAdapter ( $db );
		Zend_Registry::set ( 'dbAdapter', $db );
		Zend_Registry::set ( 'dbprefix', $options ['params'] ['prefix'] );
	}

}

